home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Sept 30, 1998
- // Author: rs
- //
- // Description:
- // This script defines the option box for the boolean surface menu item.
- //
- // Input Arguments:
- // int action
- // 1 - just execute the boolean operation
- // 2 - return the script that would do it
- //
- // Return Value:
- // None.
- //
-
- proc setOptionVars(
- int $opType,
- int $forceFactorySettings)
- {
-
- switch( $opType ) {
- case 0 :
- if( $forceFactorySettings ||
- !`optionVar -exists nurbsUnionDeleteInput` ) {
- optionVar -intValue nurbsUnionDeleteInput 1 ;
- }
- break ;
-
- case 1 :
- if( $forceFactorySettings ||
- !`optionVar -exists nurbsSubtractDeleteInput` ) {
- optionVar -intValue nurbsSubtractDeleteInput 1 ;
- }
- break ;
-
- case 2 :
- if( $forceFactorySettings ||
- !`optionVar -exists nurbsIntersecttDeleteInput` ) {
- optionVar -intValue nurbsIntersectDeleteInput 1 ;
- }
- break ;
- }
- }
- proc string assembleCmd( int $ni, int $op )
- //
- // Description :
- // To assemble boolean cmd.
- //
- {
-
- setOptionVars( $op, false ) ;
-
- int $history = `constructionHistory -q -tgl`;
- int $delInputs = 0;
- switch($op) {
- case 0 :
- $delInputs = `optionVar -q nurbsUnionDeleteInput`;
- break ;
- case 1 :
- $delInputs = `optionVar -q nurbsSubtractDeleteInput` ;
- break ;
- case 2 :
- $delInputs = `optionVar -q nurbsIntersectDeleteInput` ;
- break ;
- }
- string $cmd = "nurbsBooleanPreset 1 {";
- $cmd = $cmd + "\"" + $history + "\", ";
- $cmd = $cmd + "\"" + $ni + "\", ";
- $cmd = $cmd + "\"" + $op + "\", ";
- $cmd = $cmd + "\"" + $delInputs + "\" }";
- return $cmd;
- }
-
- proc string booleanHelp()
- {
- string $cmdHelp = "Command:<nurbsBoolean>- perform union or subtract or intersect \n";
- string $selectHelp = ("Selection: One or more NURBS surfaces followed " +
- "by a second set of NURBS surface.");
- return $cmdHelp+$selectHelp;
- }
-
- global proc nurbsBooleanCallback(
- string $parent,
- int $doIt,
- int $whichOp,
- string $goToTool )
- {
- setParent $parent;
- string $label;
-
- // get Values from controls.
- //
- int $di = `checkBoxGrp -q -v1 nurbsBooleanDeleteInputWidget`;
-
- switch( $whichOp ) {
- case 0 :
- optionVar -intValue nurbsUnionDeleteInput $di;
- $label = "Union";
- break ;
- case 1 :
- optionVar -intValue nurbsSubtractDeleteInput $di;
- $label = "Subtract";
- break ;
- case 2 :
- optionVar -intValue nurbsIntersectDeleteInput $di;
- $label = "Intersect";
- break ;
- }
-
- if( 1 == $doIt ) {
- string $list[] ;
- performBoolean( 0, $whichOp, $list , $goToTool );
- string $tmpCmd = "performBoolean( 0, " + $whichOp + ", ";
- $tmpCmd += "{ \"\"}, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd $label;
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
-
- global proc nurbsBooleanSetup(
- string $parent,
- int $forceFactorySettings,
- int $whichOp,
- string $goToTool)
- {
- // retrieve option settings.
- //
- setOptionVars( $whichOp, $forceFactorySettings );
- if( $forceFactorySettings || !`optionVar -ex booleanEuc` ) {
- optionVar -iv ("booleanEuc" + $whichOp) 0;
- }
- if( $forceFactorySettings || !`optionVar -ex booleanLac` ) {
- optionVar -iv ("booleanLac" + $whichOp) 1;
- }
- if( "" != $goToTool ) {
- scriptCtx -e -euc `optionVar -q ("booleanEuc"+$whichOp)` $goToTool;
- scriptCtx -e -lac `optionVar -q ("booleanLac"+$whichOp)` $goToTool;
- }
-
- setParent $parent;
-
- // query the option vars.
- //
- int $di ;
- switch( $whichOp ) {
- case 0 :
- $di = `optionVar -q nurbsUnionDeleteInput`;
- break ;
- case 1 :
- $di = `optionVar -q nurbsSubtractDeleteInput`;
- break ;
- case 2 :
- $di = `optionVar -q nurbsSubtractDeleteInput`;
- break ;
- }
- checkBoxGrp -e -v1 $di nurbsBooleanDeleteInputWidget ;
-
- if( "" != $goToTool ) {
- checkBoxGrp -e
- -v1 `scriptCtx -q -exitUponCompletion $goToTool`
- -v2 `scriptCtx -q -enableRootSelection $goToTool`
- scriptToolExtraWidget;
- }
- }
-
-
- proc nurbsBooleanOptions(
- int $inTheTool,
- int $whichOp,
- string $goToTool )
- //
- // Desc :
- // $whichOp = 0 (union ), 1 (subtract) , 2(intersect).
- //
- {
- // Name of the command for this option box.
- //
- string $commandName = "nurbsBoolean";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Step 1: Get the option box.
- // ============================
- string $layout = getOptionBox();
- setParent $layout;
-
- // Step 2: Pass the command name to the option box.
- // =================================================
- setOptionBoxCommandName($commandName);
-
- // Step 3: Activate the default UI template.
- // ==========================================
- setUITemplate -pushTemplate DefaultTemplate;
-
-
- // Step 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- checkBoxGrp -ncb 1 -l1 "Delete Inputs" nurbsBooleanDeleteInputWidget;
-
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 on
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Hierarchy Selection"
- -v2 on
- -on2 ("scriptCtx -e -ers true " + $goToTool)
- -of2 ("scriptCtx -e -ers false " + $goToTool)
- scriptToolExtraWidget;
-
- setParent ..;
-
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
-
- // Step 6: Customize the buttons.
- // ==============================
-
- // 'Apply' button.
- string $applyBtn = getOptionBoxApplyBtn();
-
- string $opLabel ;
- switch( $whichOp ) {
-
- case 0 :
- $opLabel = "Union" ;
- break ;
- case 1 :
- $opLabel = "Subtract" ;
- break ;
- case 2 :
- $opLabel = "Intersect" ;
- break ;
- }
-
- if( $inTheTool ) {
- button -edit -l ($opLabel + " Tool")
- -command ($callback + " " + $parent + " " + 3 + " " + $whichOp +
- " " + $goToTool )
- $applyBtn;
- } else {
- button -edit -l $opLabel
- -command ($callback + " " + $parent + " " + 1 + " " + $whichOp +
- " \"" + $goToTool + "\"" )
- $applyBtn;
-
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + " " + $whichOp +
- " \"" + $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1 + " " +
- $whichOp + " \"" + $goToTool + "\"")
- $resetBtn;
-
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("NURBS Boolean " + $opLabel + " Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "NurbsBoolean" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " " + 0 + " " +
- $whichOp + " \"" + $goToTool + "\"" );
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
-
- global proc string performBoolean(
- int $action,
- int $opType,
- string $list1[],
- string $goToTool )
- //
- // Description :
- // $action = 0 ==> do the nurbs union|subtract|intersect command.
- // $action = 1 ==>show option box.
- // $action = 2 ==>drag to shelf.
- {
- string $cmd = "";
-
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- int $ni = size($list1) ;
-
- // find only valid items.
- //
- switch( $action ) {
- case 0 :
- $cmd = `assembleCmd $ni $opType`;
- eval $cmd;
- break;
-
- case 1 :
- nurbsBooleanOptions( $inTheTool, $opType, $goToTool );
- break ;
-
- case 2 :
- $cmd = `assembleCmd $ni $opType`;
- break;
- default : break;
- }
- return $cmd;
- }
-
-